home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / NETPROG.ZIP;1 / NETPROG.TAR / rpc.courier / timedate / rdate.c < prev   
Encoding:
C/C++ Source or Header  |  1989-12-17  |  1.2 KB  |  55 lines

  1. /*
  2.  * rdate.c - client program for remote date service.
  3.  */
  4.  
  5. #include    <stdio.h>
  6. #include    "Date1_defs.h"        /* this file generated by xnscourier */
  7.  
  8. #include    <sys/types.h>
  9. #include    <netns/ns.h>        /* definition of struct ns_addr */
  10.  
  11. main(argc, argv)
  12. int    argc;
  13. char    *argv[];
  14. {
  15.     CourierConnection    *conn;        /* RPC handle */
  16.     char            *server;
  17.     struct ns_addr        ns_addr(),    /* BSD library routine */
  18.                 servaddr;
  19.     BinDateResults        binresult;    /* result from BinDate() */
  20.     StrDateResults        strresult;    /* result from StrDate() */
  21.  
  22.     if (argc != 2) {
  23.         fprintf(stderr, "usage: %s hostaddr\n", argv[0]);
  24.         exit(1);
  25.     }
  26.     server = argv[1];
  27.     servaddr = ns_addr(argv[1]);    /* convert to an ns_addr structure */
  28.  
  29.     /*
  30.      * Create the client "handle."
  31.      */
  32.  
  33.     if ( (conn = CourierOpen(&servaddr)) == NULL) {
  34.         fprintf(stderr, "Can't open connection to %s\n", server);
  35.         exit(2);
  36.     }
  37.  
  38.     /*
  39.      * First call the remote procedure BinDate().
  40.      */
  41.  
  42.     binresult = BinDate(conn, NULL);
  43.     printf("time on host %s = %ld\n", server, binresult.bindate);
  44.  
  45.     /*
  46.      * Now call the remote procedure StrDate().
  47.      */
  48.  
  49.     strresult = StrDate(conn, NULL, binresult.bindate);
  50.     printf("time on host %s = %s", server, strresult.strdate);
  51.  
  52.     CourierClose(conn);        /* close the connection cleanly */
  53.     exit(0);
  54. }
  55.